<?php
require('config.php');

        $user_id=$_REQUEST['user_id'];
        //$user_id=9;
		$sql="select * from `".$oto."_orders`,`".$oto."_order_goods`,`".$oto."_shops` where ".$oto."_orders.userId='".$user_id."' and `orderFlag`='1' and ".$oto."_orders.orderId=".$oto."_order_goods.orderId and ".$oto."_shops.shopId=".$oto."_orders.shopId and ".$oto."_orders.orderStatus='3' order by ".$oto."_orders.createTime DESC";
		$result=$db->query($sql);
		while($row=$result->fetch_assoc()){
			$order[]=$row;//将取得的所有数据赋值给person_info数组
		}
		if(isset($order))
		{
			$pan_tiao=0;
			$t=0;
			for($i=0;$i<count($order);$i++)
			{
				if($order[$i]['orderId']!=$pan_tiao)
				{
					$data[$t]['orderId']=$order[$i]['orderId'];
					$data[$t]['shopName']=$order[$i]['shopName'];
					$data[$t]['shopImg']=$order[$i]['shopImg'];
					$data[$t]['shopId']=$order[$i]['shopId'];
					$data[$t]['needPay']=$order[$i]['needPay'];
					$data[$t]['orderStatus']=$order[$i]['orderStatus'];
					$data[$t]['deliverMoney']=$order[$i]['deliverMoney'];
					$img_size=getimagesize($YAH_web.'/'.$order[$i]['shopImg']);
					$data[$t]['width']=$img_size["0"];////获取图片的宽
					$data[$t]['height']=$img_size["1"];///获取图片的高
					$t2=0;
					for($j=0;$j<count($order);$j++)
					{
						if($order[$i]['orderId']==$order[$j]['orderId'])
						{
							$data[$t]['list'][$t2]=$order[$j];
							$t2++;
						}
					}
					if($t2==0) $data[$t]['list']=[];
					$t++;
					$pan_tiao=$order[$i]['orderId'];
				}
			}
			echo json_encode($data);
		}
		else echo '[]';
?>